package com.source.lightfowl.person.dao;

import com.source.lightfowl.person.entity.Url;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UrlDao extends JpaRepository<Url,String> {

    @Query(
            value = "select * from url where `ptype`=?1 and `bpid`=?2",
            nativeQuery = true
    )
    Url findByPtypeAndBpid(String ptype, String bpid);

    @Query(value = "select * from url where id in (select uid from role_url where rid=?)", nativeQuery = true)
    List<Url> findByRid(String rid);

    @Query(
            value = "select bpid from url where urlname like %?",
            nativeQuery = true
    )
    String findBp(String url);

    @Query(
            value = "select ptype from url where urlname like %?",
            nativeQuery = true
    )
    String findP(String url);
}
